package com.sky.controller.admin;

import com.sky.result.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Version: 1.0
 * @author: wanglonghui
 * @date: 2025/10/11 17:27
 * @description:
 */


@RestController("adminShopController")
@RequestMapping("/admin/shop")
@Slf4j
public class ShopController {

    @Autowired
    private RedisTemplate<String, Object> redisTemplate;

    public static final String KEY ="SHOP_STATUS";

    /**
     * 设置店铺的营业状态
     * @param status
     * @return
     */
    public Result setShopStatus(@PathVariable Integer status) {
        log.info("设置店铺的营业状态为:{}",status==1?"营业中":"打样中");
        redisTemplate.opsForValue().set(KEY,status);
        return Result.success();
    }

    /**
     * 获取店铺的营业状态
     * @return
     */
    public Result getShopStatus() {
        Integer status = (Integer)redisTemplate.opsForValue().get(KEY);
        log.info("设置店铺的营业状态为:{}",status==1?"营业中":"打样中");
        return Result.success(status);
    }

}
